import pytest
from data.read_data import read_ihrmAdd
from scripts.hm02_api import IhrmLoginApi, IhrmAddApi
from scripts.hm03_assert import IhrmAdd


class TestIhrmAdd:
    @pytest.mark.parametrize("username,mobile,workNumber,state_code,success,code,message", read_ihrmAdd())
    # 测试方法
    def test(self, username, mobile, workNumber, state_code, success, code, message):
        # 登录
        login_data = {"mobile": "13800000002", "password": "123456"}
        login_result = IhrmLoginApi.login(login_data)
        token = login_result.json()["data"]
        # 添加员工
        add_data = {"username": username, "mobile": mobile, "workNumber": workNumber}
        add_result = IhrmAddApi.add(add_data, token)
        IhrmAdd.add_assert(add_result, state_code, success, code, message)
